home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 March
/
Chip_2002-03_cd1.bin
/
zkuste
/
delphi
/
kolekce
/
d3456
/
gmprintsuite_eval.exe
/
{app}
/
GmThumbnails.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2002-01-10
|
27KB
|
954 lines
{******************************************************************************}
{ }
{ TGmThumbnails 2.3 }
{ }
{ Copyright (c) 2001 Graham Murt - www.MurtSoft.com }
{ }
{ Feel free to e-mail me with any comments, suggestions, bugs or help at: }
{ }
{ graham@murtsoft.com }
{ }
{******************************************************************************}
unit GmThumbnails;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
extctrls, stdctrls, GmPreview, GmTypes, GmErrors, GmConst, Menus, ComCtrls;
type
// events...
TOnThumbMouseDown = procedure (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; APage: TGmPage) of object;
TGmThumbNailLayout = (gmThumbHorz, gmThumbVert, gmThumbGrid);
TGmThumbnails = class;
// *** TGmThumbnailPage ***
TGmThumbnailPage = class(TGmCustomPage)
private
FSelected: Boolean;
function GetThumbnails: TGmThumbnails;
protected
procedure Click; override;
procedure Paint; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
public
constructor Create(AOwner: TComponent); override;
end;
// *** TGmThumbnail ***
TGmThumbnail = class(TWinControl)
private
FPage: TGmThumbnailPage;
FlblPageNum: TLabel;
FOrientation: TGmOrientation;
FPageNum: integer;
FPreview: TGmPreview;
FShowCaption: Boolean;
FThumbSize: integer;
function GetCaptionHeight: integer;
function GetThumbnails: TGmThumbnails;
procedure SetCaption(const ACaption: string);
procedure SetPageNum(APageNum: integer);
procedure SetShowCaption(AShowCaption: Boolean);
procedure SetThumbSize(AThumbSize: integer);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure LabelClick(Sender: TObject);
procedure Repaint; override;
property PageNum: integer read FPageNum write SetPageNum;
property Page: TGmThumbnailPage read FPage write FPage;
property ShowCaption: Boolean read FShowCaption write SetShowCaption;
property ThumbSize: integer read FThumbSize write SetThumbSize;
end;
TGmThumbnailList = class(TList)
private
FThumbnails: TGmThumbnails;
function AddThumb: TGmThumbnail;
function GetNumThumbs: integer;
function GetThumbnail(APageNum: integer): TGmThumbnail;
procedure DeleteThumb(APageNum: integer);
procedure SetThumbnail(APageNum: integer; AThumbnail: TGmThumbnail);
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent);
destructor Destroy; override;
procedure Clear; {$IFNDEF VER100} override; {$ENDIF}
property Thumbnail[APageNum: integer]: TGmThumbnail read GetThumbnail write SetThumbnail;
{ Public declarations }
published
{ Published declarations }
end;
TGmProgressPanel = class(TCustomPanel)
private
FProgressBar: TProgressBar;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Init;
procedure SetPercent(Percent: integer);
end;
TGmThumbnails = class(TScrollingWinControl)
private
FBorderStyle: TBorderStyle;
FEnabled: Boolean;
FGridWidth: integer;
FItemIndex: integer;
FHighlight: Boolean;
FLayout: TGmThumbNailLayout;
FLoadingUpdate: Boolean;
FPageCaption: string;
FPreview: TGmPreview;
//FProgressBar: TProgressBar;
//FProgressPercent: TLabel;
FProgressPanel: TGmProgressPanel;
FScrollIntoView: Boolean;
FShadow: TGmShadow;
FShowCaption: Boolean;
FShowProgress: Boolean;
FThumbList: TGmThumbnailList;
FThumbPopup: TPopupMenu;
FThumbSize: integer;
FTempValue: Boolean;
// events...
FOnThumbClick: TOnThumbMouseDown;
function AddThumb: TGmThumbnail;
function GetShadow: TGmShadow;
procedure DeleteLastThumb;
procedure DeleteThumb(APageNum: integer);
procedure SetBorderStyle(AStyle: TBorderStyle);
procedure SetGridWidth(AGridWidth: integer);
procedure SetItemIndex(AIndex: integer);
procedure SetHighlight(AValue: Boolean);
procedure SetLayout(ALayout: TGmThumbNailLayout);
procedure SetPageCaption(const ACaption: string);
procedure SetPreview(APreview: TGmPreview);
procedure SetShowCaption(AShowCaption: Boolean);
procedure SetThumbSize(AThumbSize: integer);
procedure SetThumbPopup(APopup: TPopupMenu);
procedure ShadowChanged(Sender: TObject);
protected
function SelectedPageNum: integer;
procedure CreateParams(var Params: TCreateParams); override;
procedure NumPagesChanged(var Message: TMessage); message GM_NUMPAGES_CHANGED;
procedure OrientationChanged(var Message: TMessage); message GM_ORIENTATION_CHANGED;
procedure PageChanged(var Message: TMessage); message GM_PAGE_CHANGED;
procedure PageUpdated(var Message: TMessage); message GM_PAGE_UPDATED;
procedure PageOrientationChanged(var Message: TMessage); message GM_PAGE_ORIENTATION_CHANGED;
procedure PaperSizeChanged(var Message: TMessage); message GM_PAPER_SIZE_CHANGED;
procedure PreviewCleared(var Message: TMessage); message GM_PREVIEW_CLEARED;
procedure PreviewLoading(var Message: TMessage); message GM_LOADING;
procedure ResizeThumbnails;
procedure ScrollToThumb;
procedure SetEnabled(AEnabled: Boolean); {$IFNDEF VER100} override; {$ENDIF}
procedure HideAll;
procedure ShowAll;
procedure SyncronizePages(ANumPages: integer);
procedure RepositionThumbnails(DisplayProgress: Boolean);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure UpdateThumbnails;
// private...
procedure RedrawThumbs;
property ItemIndex: integer read FItemIndex write SetItemIndex;
published
{properties available from Delphi 4...}
{$IFNDEF VER100}
property Anchors;
property Constraints;
{$ENDIF}
property Align;
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
property Color;
property Enabled: Boolean read FEnabled write SetEnabled;
property GridWidth: integer read FGridWidth write SetGridWidth default 4;
property Highlight: boolean read FHighlight write SetHighlight default True;
property Layout: TGmThumbNailLayout read FLayout write SetLayout default gmThumbHorz;
property PageCaptions: string read FPageCaption write SetPageCaption;
property Preview: TGmPreview read FPreview write SetPreview;
property ScrollIntoView: Boolean read FScrollIntoView write FScrollIntoView default True;
property Shadow: TGmShadow read GetShadow;
property ShowCaption: Boolean read FShowCaption write SetShowCaption default True;
property ShowProgress: Boolean read FShowProgress write FShowProgress default False;
property ShowHint;
property TabOrder;
property ThumbSize: integer read FThumbSize write SetThumbSize default 4;
property ThumbPopup: TPopupMenu read FThumbPopup write SetThumbPopup;
property Visible;
property UpdateWhileLoading: Boolean read FLoadingUpdate write FLoadingUpdate default False;
// events...
property OnThumbMouseDown: TOnThumbMouseDown read FOnThumbClick write FOnThumbClick;
end;
implementation
//------------------------------------------------------------------------------
// TGmThumbnailPage...
constructor TGmThumbnailPage.Create(AOwner: TComponent);
begin
inherited;
FSelected := False;
end;
function TGmThumbnailPage.GetThumbnails: TGmThumbnails;
var
AThumbnail: TGmThumbnail;
begin
AThumbnail := TGmThumbnail(Owner);
Result := TGmThumbnails(AThumbnail.Owner);
end;
procedure TGmThumbnailPage.Click;
var
AThumbnail: TGmThumbnail;
begin
AThumbnail := TGmThumbnail(Owner);
GetThumbnails.FPreview.CurrentPage := AThumbnail.PageNum;
end;
procedure TGmThumbnailPage.Paint;
begin
inherited;
if (FSelected) and (GetThumbnails.Highlight) then
begin
Canvas.Pen.Color := clBlue;
Canvas.Brush.Style := bsClear;
Canvas.Rectangle(PageRect.Left, PageRect.Top, PageRect.Right, PageRect.Bottom);
end;
end;
procedure TGmThumbnailPage.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
APreview: TGmPreview;
ItemIndex: integer;
begin
inherited;
APreview := GetThumbnails.Preview;
ItemIndex := GetThumbnails.ItemIndex;
if Assigned(GetThumbnails.FOnThumbClick) then
GetThumbnails.FOnThumbClick(Self, Button, Shift, APreview.Pages[ItemIndex+1]);
end;
//------------------------------------------------------------------------------
// TGmThumbnail routines...
constructor TGmThumbnail.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FPage := TGmThumbnailPage.Create(Self);
FlblPageNum := TLabel.Create(Self);
FShowCaption := TGmThumbnails(AOwner).ShowCaption;
FPage.Parent := Self;
FPreview := TGmThumbnails(AOwner).Preview;
//SetThumbSize(5);
FlblPageNum.AutoSize := False;
FlblPageNum.Left := 0;
FlblPageNum.Align := alBottom;
FlblPageNum.Alignment := taCenter;
FlblPageNum.Parent := Self;
FlblPageNum.OnClick := LabelClick;
end;
destructor TGmThumbnail.Destroy;
begin
FPage.Free;
FlblPageNum.Free;
inherited Destroy;
end;
procedure TGmThumbnail.LabelClick(Sender: TObject);
begin
FPage.Click;
end;
procedure TGmThumbnail.Repaint;
begin
inherited;
if (FPage.FSelected) and (GetThumbnails.Highlight) then
FlblPageNum.Font.Color := clBlue
else
FlblPageNum.Font.Color := clBlack;
end;
function TGmThumbnail.GetCaptionHeight: integer;
begin
// if FShowCaption then
Result := 18
//else
// Result := 0;
end;
function TGmThumbnail.GetThumbnails: TGmThumbnails;
begin
Result := TGmThumbnails(Owner);
end;
procedure TGmThumbnail.SetCaption(const ACaption: string);
var
TokenizedCaption: string;
TokenIndex: integer;
begin
TokenizedCaption := ACaption;
while Pos('#', TokenizedCaption) > 0 do
begin
TokenIndex := Pos('#', TokenizedCaption);
Delete(TokenizedCaption, TokenIndex, 1);
Insert(IntToStr(FPageNum), TokenizedCaption, TokenIndex);
end;
FlblPageNum.Caption := TokenizedCaption;
end;
procedure TGmThumbnail.SetPageNum(APageNum: integer);
begin
FPageNum := APageNum;
end;
procedure TGmThumbnail.SetShowCaption(AShowCaption: Boolean);
begin
FlblPageNum.Visible := AShowCaption;
//GetThumbnails.SyncronizePages(GetThumbnails.Preview.NumPages);
SetThumbSize(FThumbSize);
end;
procedure TGmThumbnail.SetThumbSize(AThumbSize: integer);
var
ThumbHeight,
ThumbWidth : integer;
CaptionHeight: integer;
AShadowWidth: integer;
begin
CaptionHeight := GetCaptionHeight;
//if FThumbSize <> AThumbSize then
begin
FThumbSize := AThumbSize;
AShadowWidth := FPage.Shadow.Width;
ThumbWidth := Round((FPreview.PageWidth.AsMillimeters / 20) * (FThumbSize+1));
ThumbHeight := Round((FPreview.PageHeight.AsMillimeters / 20) * (FThumbSize+1));
if FOrientation <> FPreview.Orientation then
begin
SwapValues(ThumbWidth, ThumbHeight);
end;
Width := ThumbWidth+AShadowWidth +8;
Height := ThumbHeight+CaptionHeight+AShadowWidth +8;
end;
FPage.SetBounds(4,4,Width-(8-FPage.Shadow.Width), (Height-CaptionHeight)-(8-FPage.Shadow.Width));
end;
//------------------------------------------------------------------------------
// *** TGmThumbnailList ***
constructor TGmThumbnailList.Create(AOwner: TComponent);
begin
inherited Create;
FThumbnails := TGmThumbnails(AOwner);
end;
destructor TGmThumbnailList.Destroy;
begin
Clear;
inherited Destroy;
end;
procedure TGmThumbnailList.Clear;
var
ICount: integer;
begin
for ICount := GetNumThumbs downto 1 do
DeleteThumb(ICount);
end;
procedure TGmThumbnailList.DeleteThumb(APageNum: integer);
begin
TGmThumbnail(Self[APageNum-1]).Free;
Self.Delete(APageNum-1);
end;
procedure TGmThumbnailList.SetThumbnail(APageNum: integer; AThumbnail: TGmThumbnail);
begin
Self[APageNum-1] := AThumbnail;
end;
function TGmThumbnailList.AddThumb: TGmThumbnail;
begin
Result := TGmThumbnail.Create(FThumbnails);
Add(Result);
Result.PageNum := Count;
end;
function TGmThumbnailList.GetNumThumbs: integer;
begin
Result := Count;
end;
function TGmThumbnailList.GetThumbnail(APageNum: integer): TGmThumbnail;
begin
Result := TGmThumbnail(Self[APageNum-1])
end;
//------------------------------------------------------------------------------
// *** TGmProgressPanel ***
constructor TGmProgressPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Height := 36;
BorderWidth := 9;
FProgressBar := TProgressBar.Create(Self);
FProgressBar.Align := alClient;
FProgressBar.Parent := Self;
Init;
end;
destructor TGmProgressPanel.Destroy;
begin
FProgressBar.Free;
inherited Destroy;
end;
procedure TGmProgressPanel.Init;
begin
FProgressBar.Position := 0;
FProgressBar.Max := 100;
end;
procedure TGmProgressPanel.SetPercent(Percent: integer);
begin
FProgressBar.Position := Percent;
Repaint;
end;
//------------------------------------------------------------------------------
// *** TGmThumbnails ***
constructor TGmThumbnails.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FThumbList := TGmThumbnailList.Create(Self);
FBorderStyle := bsSingle;
FEnabled := True;
FHighlight := True;
FProgressPanel := TGmProgressPanel.Create(Self);
FShadow := TGmShadow.Create(Self);
FShadow.OnChange := ShadowChanged;
FShowCaption := True;
FShowProgress := False;
FLayout := gmThumbHorz;
FGridWidth := 4;
FPageCaption := 'Page #';
FScrollIntoView := True;
FThumbSize := 4;
FLoadingUpdate := False;
Width := 265;
Height := 120;
end;
destructor TGmThumbnails.Destroy;
begin
if Assigned(FPreview) then FPreview.RemoveAssociatedComponent(Self);
FProgressPanel.Free;
FThumbList.Free;
inherited Destroy;
end;
procedure TGmThumbnails.CreateParams(var Params: TCreateParams);
const
BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER);
begin
inherited CreateParams(Params);
with Params do
begin
Style := Style or BorderStyles[FBorderStyle];
if NewStyleControls and Ctl3D and (FBorderStyle = bsSingle) then
begin
Style := Style and not WS_BORDER;
ExStyle := ExStyle or WS_EX_CLIENTEDGE;
end;
end;
end;
function TGmThumbnails.SelectedPageNum: integer;
begin
Result := FPreview.CurrentPage;
end;
procedure TGmThumbnails.NumPagesChanged(var Message: TMessage);
begin
if FEnabled then
begin
SyncronizePages(Message.WParam);
RepositionThumbnails(FShowProgress);
end;
end;
procedure TGmThumbnails.PageChanged(var Message: TMessage);
var
ICount: integer;
APage: TGmThumbnail;
begin
if (FEnabled) then
begin
FItemIndex := Message.WParam-1;
for ICount := 1 to FThumbList.GetNumThumbs do
begin
APage := FThumbList.Thumbnail[ICount];
if APage.FPage.FSelected then
begin
APage.FPage.FSelected := False;
APage.Repaint;
end;
end;
APage := FThumbList.Thumbnail[FItemIndex+1];
APage.FPage.FSelected := True;
APage.Repaint;
ScrollToThumb;
end;
end;
procedure TGmThumbnails.PageUpdated(var Message: TMessage);
begin
if FEnabled then
begin
if FThumbList.GetNumThumbs <> FPreview.NumPages then
begin
FEnabled := False;
SetEnabled(True);
end;
FThumbList.Thumbnail[Message.WParam].Repaint;
end;
end;
procedure TGmThumbnails.OrientationChanged(var Message: TMessage);
var
ICount: integer;
begin
if FEnabled then
begin
for ICount := 1 to FThumbList.GetNumThumbs do
FThumbList.Thumbnail[ICount].FOrientation := FPreview.Orientation;
HideAll;
ResizeThumbnails;
RepositionThumbnails(FShowProgress);
end;
end;
procedure TGmThumbnails.PageOrientationChanged(var Message: TMessage);
begin
if FEnabled then
begin
FThumbList.Thumbnail[Message.WParam].FOrientation := FPreview.Pages[Message.WParam].Orientation;
FThumbList.Thumbnail[Message.WParam].SetThumbSize(FThumbSize);
RepositionThumbnails(FShowProgress);
end;
end;
procedure TGmThumbnails.PaperSizeChanged(var Message: TMessage);
begin
if FEnabled then
begin
UpdateThumbnails;
end;
end;
procedure TGmThumbnails.PreviewCleared(var Message: TMessage);
begin
if FEnabled then
begin
FThumbList.Clear;
DisableAutoRange;
SyncronizePages(1);
FThumbList.Thumbnail[1].Page.FSelected := True;
RepositionThumbnails(False);
EnableAutoRange;
end;
end;
procedure TGmThumbnails.PreviewLoading(var Message: TMessage);
begin
if Message.WParam = 0 then
begin
// start of loading...
if (not FLoadingUpdate) then
begin
FTempValue := FEnabled;
FEnabled := False;
end;
end
else
if Message.WParam = 1 then
begin
// end of loading...
if (not FLoadingUpdate) then
begin
Enabled := FTempValue;
end;
end;
end;
procedure TGmThumbnails.RedrawThumbs;
var
ICount: integer;
begin
FPreview.MessagesEnabled := False;
for ICount := 1 to FThumbList.GetNumThumbs do
begin
FPreview.Pages[ICount].DrawPage;
FThumbList.Thumbnail[ICount].FPage.SetPageMetafile(FPreview.Metafile[ICount], True);
end;
FPreview.MessagesEnabled := True;
end;
procedure TGmThumbnails.SetBorderStyle(AStyle: TBorderStyle);
begin
if FBorderStyle <> AStyle then
begin
FBorderStyle := AStyle;
RecreateWnd;
end;
end;
procedure TGmThumbnails.SetEnabled(AEnabled: Boolean);
begin
inherited;
if FEnabled <> AEnabled then
begin
FEnabled := AEnabled;
UpdateThumbnails;
end;
end;
procedure TGmThumbnails.HideAll;
var
ICount: integer;
begin
for ICount := 1 to FThumbList.GetNumThumbs do
FThumbList.Thumbnail[ICount].Parent := nil;
end;
procedure TGmThumbnails.ShowAll;
var
ICount: integer;
begin
for ICount := FThumbList.GetNumThumbs downto 1 do
FThumbList.Thumbnail[ICount].visible := True;
end;
procedure TGmThumbnails.UpdateThumbnails;
var
PageNum: integer;
begin
if (FEnabled) and (Assigned(FPreview)) then
begin
SyncronizePages(FPreview.NumPages);
RedrawThumbs;
RepositionThumbnails(FShowProgress);
PageNum := FPreview.CurrentPage;
SendMessage(Self.Handle, GM_PAGE_CHANGED, PageNum, 0);
end;
end;
procedure TGmThumbnails.SetGridWidth(AGridWidth: integer);
begin
FGridWidth := AGridWidth;
if FLayout = gmThumbGrid then
RepositionThumbnails(FShowProgress);
end;
procedure TGmThumbnails.SetItemIndex(AIndex: integer);
begin
if (AIndex <> FItemIndex) and (AIndex >= 0) and (AIndex < FThumbList.GetNumThumbs) then
begin
SendMessage(Self.Handle, GM_PAGE_CHANGED, AIndex+1, 0);
end;
end;
procedure TGmThumbnails.SetHighlight(AValue: Boolean);
begin
if FHighlight <> AValue then
begin
FHighLight := AValue;
FThumbList.Thumbnail[ItemIndex+1].Repaint;
end;
end;
procedure TGmThumbnails.SetLayout(ALayout: TGmThumbNailLayout);
begin
if FLayout <> ALayout then
begin
FLayout := ALayout;
RepositionThumbnails(FShowProgress);
end;
end;
procedure TGmThumbnails.SetPageCaption(const ACaption: string);
var
ICount: integer;
begin
if FPageCaption <> ACaption then
begin
FPageCaption := ACaption;
for ICount := 1 to FThumbList.GetNumThumbs do
FThumbList.Thumbnail[ICount].SetCaption(FPageCaption);
end;
end;
procedure TGmThumbnails.SetPreview(APreview: TGmPreview);
begin
if Assigned(APreview) then
begin
FPreview := APreview;
FPreview.AddAssociatedComponent(Self);
if FEnabled then
begin
SyncronizePages(FPreview.NumPages);
FThumbList.Thumbnail[FPreview.CurrentPage].FPage.FSelected := True;
FThumbList.Thumbnail[FPreview.CurrentPage].Repaint;
RepositionThumbnails(FShowProgress);
end;
end
else
FPreview := nil;
end;
procedure TGmThumbnails.SetShowCaption(AShowCaption: Boolean);
var
ICount: integer;
begin
for ICount := 1 to FThumbList.GetNumThumbs do
FThumbList.Thumbnail[ICount].ShowCaption := AShowCaption;
end;
function TGmThumbnails.AddThumb: TGmThumbnail;
begin
Result := FThumbList.AddThumb;
Result.FOrientation := FPreview.Orientation;
Result.SetThumbSize(FThumbSize);
Result.Page.SetPageMetafile(FPreview.MetaFile[Result.PageNum], True);
Result.PopupMenu := FThumbPopup;
Result.SetCaption(FPageCaption);
end;
procedure TGmThumbnails.ResizeThumbnails;
var
ICount: integer;
begin
if FEnabled then
begin
for ICount := 1 to FThumbList.GetNumThumbs do
FThumbList.Thumbnail[ICount].SetThumbSize(FThumbSize);
end;
end;
procedure TGmThumbnails.ScrollToThumb;
begin
if (FScrollIntoView) and (FItemIndex <> -1) then
ScrollInView(FThumbList.Thumbnail[FItemIndex+1]);
end;
function TGmThumbnails.GetShadow: TGmShadow;
begin
Result := FShadow;
end;
procedure TGmThumbnails.DeleteLastThumb;
begin
DeleteThumb(FThumbList.Count);
end;
procedure TGmThumbnails.DeleteThumb(APageNum: integer);
begin
FThumbList.DeleteThumb(APageNum);
end;
procedure TGmThumbnails.RepositionThumbnails;
var
ICount: integer;
AThumbnail: TGmThumbnail;
CurrentX,
CurrentY: integer;
CurrentCol,
//HorzPos, VertPos: integer;
RowHeight: integer;
NumThumbs: integer;
LastPercent: integer;
begin
if FEnabled then
begin
NumThumbs := FThumbList.GetNumThumbs;
CurrentX := 0;
CurrentY := 0;
LastPercent := 0;
HorzScrollBar.Position := 0;
VertScrollBar.Position := 0;
//Autoscroll := False;
DisableAutoRange;
if DisplayProgress then
with FProgressPanel do
begin
Top := (Self.Height div 2) -10;
Width := Self.ClientWidth - 32;
Left := 16;
Ctl3D := False;
Init;
Parent := Self;
Repaint;
end;
HideAll;
case FLayout of
gmThumbHorz:
begin
for ICount := 1 to NumThumbs do
begin
AThumbnail := FThumbList.Thumbnail[ICount];
AThumbnail.SetBounds(CurrentX, 0, AThumbnail.Width, AThumbnail.Height);
Inc(CurrentX, AThumbnail.Width);
AThumbnail.Parent := Self;
Application.ProcessMessages;
if (DisplayProgress) and (LastPercent <> Round((ICount/NumThumbs)*100)) then
begin
LastPercent := Round((ICount/NumThumbs)*100);
FProgressPanel.BringToFront;
FProgressPanel.SetPercent(LastPercent);
end;
end;
end;
gmThumbVert:
begin
for ICount := 1 to NumThumbs do
begin
AThumbnail := FThumbList.Thumbnail[ICount];
AThumbnail.Parent := nil;
AThumbnail.SetBounds(0, CurrentY, AThumbnail.Width, AThumbnail.Height);
Inc(CurrentY, AThumbnail.Height);
AThumbnail.Parent := Self;
Application.ProcessMessages;
if (DisplayProgress) and (LastPercent <> Round((ICount/NumThumbs)*100)) then
begin
LastPercent := Round((ICount/NumThumbs)*100);
FProgressPanel.BringToFront;
FProgressPanel.SetPercent(LastPercent);
end;
end;
end;
gmThumbGrid:
begin
CurrentCol := 1;
RowHeight := 1;
for ICount := 1 to NumThumbs do
begin
AThumbnail := FThumbList.Thumbnail[ICount];
AThumbnail.SetBounds(CurrentX, CurrentY, AThumbnail.Width, AThumbnail.Height);
Inc(CurrentX, AThumbnail.Width);
AThumbnail.Parent := Self;
Application.ProcessMessages;
RowHeight := MaxInt(RowHeight, AThumbnail.Height);
Inc(CurrentCol);
if CurrentCol > FGridWidth then
begin
CurrentCol := 1;
CurrentX := 0;
Inc(CurrentY, RowHeight);
RowHeight := 1;
end;
if (DisplayProgress) and (LastPercent <> Round((ICount/NumThumbs)*100)) then
begin
LastPercent := Round((ICount/NumThumbs)*100);
FProgressPanel.BringToFront;
FProgressPanel.SetPercent(LastPercent);
end;
end;
end;
end;
FProgressPanel.Parent := nil;
end;
EnableAutoRange;
//AutoScroll := True;
end;
procedure TGmThumbnails.SyncronizePages(ANumPages: integer);
var
ICount: integer;
begin
if FEnabled then
begin
if FThumbList.Count < ANumPages then
while FThumbList.Count < ANumPages do
with AddThumb do
begin
ICount := FThumbList.Count;
FThumbList.Thumbnail[ICount].FOrientation := FPreview.Pages[ICount].Orientation;
FThumbList.Thumbnail[ICount].FPage.Shadow.Assign(FShadow);
FThumbList.Thumbnail[ICount].FlblPageNum.Visible := ShowCaption;
end
else
if FThumbList.Count > ANumPages then
while FThumbList.Count > ANumPages do
DeleteLastThumb;
end;
end;
procedure TGmThumbnails.SetThumbSize(AThumbSize: integer);
var
ICount: integer;
begin
FThumbSize := AThumbSize;
for ICount := 1 to FThumbList.GetNumThumbs do
FThumbList.Thumbnail[ICount].SetThumbSize(FThumbSize);
RepositionThumbnails(FShowProgress);
end;
procedure TGmThumbNails.SetThumbPopup(APopup: TPopupMenu);
var
ICount: integer;
begin
for ICount := 1 to FThumbList.GetNumThumbs do
FThumbList.Thumbnail[ICount].FPage.PopupMenu := APopup;
FThumbPopup := APopup;
end;
procedure TGmThumbnails.ShadowChanged(Sender: TObject);
begin
if Assigned(FPreview) then
SyncronizePages(FPreview.NumPages);
end;
end.